﻿

using Maticsoft.BLL;
using Maticsoft.Model;

using System;
using System.Collections.Specialized;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Utils;

public partial class WebPage_Shezhi_GongGao : SystemBBasePage
{

    private Maticsoft.BLL.Category cateGory = new Maticsoft.BLL.Category();

    private NameValueCollection nvc = new NameValueCollection();
    private StringBuilder sb1 = new StringBuilder();
    private StringBuilder sb2 = new StringBuilder();

    private Maticsoft.BLL.System systems = new Maticsoft.BLL.System();
    private WebSiteHelper webSiteHelper = new WebSiteHelper();

    private void addSystem()
    {
        Maticsoft.Model.System model = new Maticsoft.Model.System();
        model = this.systems.GetModel(1);
        this.nvc = new NameValueCollection();
        string[] values = base.Request.Form.GetValues("cityid");
        if (values != null)
        {
            for (int i = 0; i < values.Length; i++)
            {
                string str = base.Request.Form["bulletin" + values[i]];
                this.nvc.Add(values[i], str);
            }
        }
        model.Gobalbulletin = base.Request.Form["bulletin"].ToString();
        model.Bulletin = WebSiteHelper.BulletinListToJson(this.nvc);
        this.systems.Update(model);
        base.SetSuccess("设置成功");
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (base.Request.HttpMethod == "POST")
        {
            this.addSystem();
        }
        this.setCity();
        this.HeaderControl1.Select = "shezhi";
        this.SheZhi1.Select = "Go";
    }

    private void setCity()
    {
        foreach (Maticsoft.Model.System system in this.systems.GetModelList("Id=1"))
        {
            this.bulletin.Value = system.Gobalbulletin;
            this.nvc = WebSiteHelper.BulletinJsonToList(system.Bulletin);
        }
        foreach (Maticsoft.Model.Category category in this.cateGory.GetModelList("Zone='city'"))
        {
            this.sb2.Append("<label>" + category.Name + "</label>");
            this.sb2.Append("<input name='cityid' type='hidden' value='" + category.Id + "' />");
            this.sb2.Append(string.Concat(new object[] { " <textarea cols='45' rows='5' name='bulletin", category.Id, "' class=\"f-textarea xheditor {upImgUrl:'/upload.aspx?immediate=1'}\">", this.nvc[category.Id.ToString()], "</textarea>" }));
        }
        this.Literal1.Text = this.sb1.ToString();
        this.Literal2.Text = this.sb2.ToString();
    }
}


